var t = getApp();

Page({
    data: {
        active: "0",
        title: "",
        page: 1,
        recordsList: []
    },
    onLoad: function(t) {
        this.setData({
            store_id: t.store_id
        }), this.getData();
    },
    goDetail: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.name;
        wx.navigateTo({
            url: "/packageA/member/balance/details/details?id=" + a + "&name=" + e
        });
    },
    swichTabTItem: function(t) {
        console.log(t), this.setData({
            active: t.detail.index,
            page: 1,
            recordsList: []
        }), this.getData();
    },
    getData: function() {
        var a = this, e = "0" == this.data.active ? "0" : "1" == this.data.active ? "1" : "-1", s = t.getNetAddresss("plugin.store-cashier.frontend.store.balance.log.index");
        t._postNetWork({
            url: s,
            data: {
                store_id: this.data.store_id,
                log_type: e
            },
            success: function(t) {
                var e = t.data;
                console.log(e), a.setData({
                    recordsList: e.data.list.data,
                    last_page: e.data.list.last_page,
                    title: e.data.title
                }), wx.setNavigationBarTitle({
                    title: "".concat(e.data.title, "明细")
                });
            },
            fail: function(t) {
                wx.showToast({
                    title: t.data.msg,
                    duration: 1e3,
                    icon: "none"
                });
            }
        });
    },
    getMoreData: function() {
        var a = this, e = "0" == this.data.active ? "0" : "1" == this.data.active ? "1" : "-1", s = t.getNetAddresss("plugin.store-cashier.frontend.store.balance.log.index");
        t._postNetWork({
            url: s,
            data: {
                store_id: this.data.store_id,
                log_type: e,
                page: this.data.page
            },
            success: function(t) {
                var e = t.data;
                console.log(e), a.setData({
                    recordsList: a.data.recordsList.concat(e.data.list.data),
                    last_page: e.data.list.last_page
                });
            },
            fail: function(t) {
                wx.showToast({
                    title: t.data.msg,
                    duration: 1e3,
                    icon: "none"
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.page >= this.data.last_page || (this.setData({
            page: this.data.page + 1
        }), this.getMoreData());
    },
    onShareAppMessage: function() {}
});